home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / WorldScript.h < prev   
Encoding:
C/C++ Source or Header  |  1995-03-22  |  10.0 KB  |  362 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __WORLDSCRIPT__
  21. #define __WORLDSCRIPT__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __TRAPS__
  30. #include <Traps.h>
  31. #endif
  32.  
  33. #ifndef __QUICKDRAWTEXT__
  34. #include <QuickdrawText.h>
  35. #endif
  36. /*    #include <MixedMode.h>                                        */
  37.  
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41.  
  42. #if PRAGMA_ALIGN_SUPPORTED
  43. #pragma options align=mac68k
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT_SUPPORTED
  47. #pragma import on
  48. #endif
  49.  
  50.  
  51. enum {
  52.     kVariableLengthArray        = 1
  53. };
  54.  
  55. typedef UInt16 WSIOffset;
  56.  
  57. typedef UInt8 WSIByteCount;
  58.  
  59. typedef UInt8 WSIByteIndex;
  60.  
  61. /* offset from start of sub-table to row in state table */
  62. typedef UInt16 WSIStateOffset;
  63.  
  64. typedef UInt32 WSITableOffset;
  65.  
  66. typedef UInt16 WSISubtableOffset;
  67.  
  68. typedef UInt16 WSIGlyphcode;
  69.  
  70. typedef UInt32 WSITableIdentifiers;
  71.  
  72.  
  73. enum {
  74.     kScriptSettingsTag            = 'info',
  75.     kMetamorphosisTag            = 'mort',
  76.     kGlyphExpansionTag            = 'g2g#',
  77.     kPropertiesTag                = 'prop',
  78.     kJustificationTag            = 'kash',
  79.     kCharToGlyphTag                = 'cmap',
  80.     kGlyphToCharTag                = 'pamc',
  81.     kFindScriptRunTag            = 'fstb'
  82. };
  83.  
  84. /****             L O O K U P    T A B L E    T Y P E S        ****/
  85. enum {
  86.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  87.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  88.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  89.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  90.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  91. };
  92.  
  93. typedef unsigned short WSILookupTableFormat;
  94.  
  95. typedef unsigned short WSILookupValue;
  96.  
  97. /* An offset from the beginning of the lookup table */
  98. typedef unsigned short WSILookupOffset;
  99.  
  100. /*    FORMAT SPECIFIC DEFINITIONS */
  101. /*
  102.         lookupSimpleArray:
  103.         
  104.         This is a simple array which maps all glyphs in the font
  105.         to lookup values.
  106.     */
  107. struct WSILookupArrayHeader {
  108.     WSILookupValue                    lookupValues[1];            /* The array of values indexed by glyph code */
  109. };
  110. typedef struct WSILookupArrayHeader WSILookupArrayHeader;
  111.  
  112. /*
  113.         lookupTrimmedArray:
  114.         
  115.         This is a single trimmed array which maps a single range
  116.         of glyhs in the font to lookup values.
  117.     */
  118. struct WSILookupTrimmedArrayHeader {
  119.     WSIGlyphcode                    firstGlyph;
  120.     WSIGlyphcode                    limitGlyph;
  121.     WSILookupValue                    valueArray[1];
  122. };
  123. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  124.  
  125. /* The format specific part of the subtable header */
  126. union WSILookupFormatSpecificHeader {
  127.     WSILookupArrayHeader            lookupArray;
  128.     WSILookupTrimmedArrayHeader        trimmedArray;
  129. };
  130. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  131.  
  132. /* The overall subtable header */
  133. struct WSILookupTableHeader {
  134.     WSILookupTableFormat            format;                        /* table format */
  135.     WSILookupFormatSpecificHeader    fsHeader;                    /* format specific header */
  136. };
  137. typedef struct WSILookupTableHeader WSILookupTableHeader;
  138.  
  139. /****        G L Y P H    E X P A N S I O N    ****/
  140.  
  141. enum {
  142. /* fixed 1.0 */
  143.     kCurrentGlyphExpansionVersion = 0x00010000
  144. };
  145.  
  146. typedef unsigned short GlyphExpansionFormats;
  147.  
  148.  
  149. enum {
  150.     GlyphExpansionLookupFormat    = 1,
  151.     GlyphExpansionContextualFormat = 2
  152. };
  153.  
  154. struct ExpandedGlyphCluster {
  155.     WSIByteCount                    numGlyphs;
  156.     WSIByteIndex                    bestGlyph;
  157.     WSIGlyphcode                    glyphs[1];
  158. };
  159. typedef struct ExpandedGlyphCluster ExpandedGlyphCluster;
  160.  
  161. struct ExpandedGlyphOffset {
  162.     WSIGlyphcode                    glyph;
  163.     WSIOffset                        offset;                        /* offset to ExpandedGlyphCluster */
  164. };
  165. typedef struct ExpandedGlyphOffset ExpandedGlyphOffset;
  166.  
  167. struct GlyphExpansionTable {
  168.     Fixed                            version;
  169.     short                            format;
  170.     short                            expansionNumer;
  171.     short                            expansionDenom;                /* num/denom ratio for expansion <2> */
  172.     union {
  173.         struct GlyphExpansionStateTable {
  174.             WSISubtableOffset                stateTableOffset;
  175.             WSISubtableOffset                classTableOffset;
  176.             WSISubtableOffset                actionTableOffset;    /* state, class and actions tables follow here... */
  177.         }                                stateTable;
  178.         WSILookupTableHeader            lookup;                    /* expanded glyph clusters follow here... */
  179.     }                                table;
  180. };
  181. typedef struct GlyphExpansionTable GlyphExpansionTable;
  182.  
  183. /* Glyph-to-Character constants and types  */
  184.  
  185. enum {
  186.     kCurrentGlyphToCharVersion    = (Fixed)0x00010100
  187. };
  188.  
  189. typedef unsigned short GlyphToCharLookupFormats;
  190.  
  191.  
  192. enum {
  193.     kGlyphToCharLookup8Format    = 1,
  194.     kGlyphToCharLookup16Format    = 2,
  195.     kGlyphToCharLookup32Format    = 3
  196. };
  197.  
  198. typedef UInt8 GlyphToCharFontIndex;
  199.  
  200. typedef UInt8 QDGlyphcode;
  201.  
  202. struct GlyphToCharActionTable {
  203.     WSISubtableOffset                fontNameOffset;                /* offset relative to this table */
  204.     WSILookupTableHeader            actions;                    /* only support lookupSimpleArray format for now */
  205. };
  206. typedef struct GlyphToCharActionTable GlyphToCharActionTable;
  207.  
  208. struct GlyphToCharActionHeader {
  209.     short                            numTables;                    /* 0..n */
  210.     WSISubtableOffset                offsets[1];                    /* offsets from start of action table header */
  211. };
  212. typedef struct GlyphToCharActionHeader GlyphToCharActionHeader;
  213.  
  214. struct GlyphToCharHeader {
  215.     Fixed                            version;
  216.     WSISubtableOffset                actionOffset;                /* offset to GlyphToCharActionHeader */
  217.     short                            format;                        /* size of font mask */
  218.     WSILookupTableHeader            mappingTable;
  219. };
  220. typedef struct GlyphToCharHeader GlyphToCharHeader;
  221.  
  222. /* JUSTIFICATION TYPES
  223.     WorldScript supports justification of text using insertion. The justification
  224.     table specifies a insertion string to insert between 2 specified glyphs.
  225.     Each combination of inter-glyph boundary can be assigned a justification priority,
  226.     the higher the priority the more justification strings inserted at that position.
  227.     
  228.     The priorities for each inter-glyph boundary are specified by the justification table's
  229.     state table.
  230.     
  231.     Special handling is done for scripts which use spaces to justify, because the width of 
  232.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  233.     per inserting string is specified in the justification table.
  234.  
  235. */
  236.  
  237. enum {
  238. /* 1.0 not supported */
  239.     kCurrentJustificationVersion = 0x0200
  240. };
  241.  
  242. enum {
  243.     kJustificationStateTableFormat = 1
  244. };
  245.  
  246. enum {
  247. /* WSI's internal limitation <12> */
  248.     kMaxJustificationStringLength = 13
  249. };
  250.  
  251. typedef UInt8 WSIJustificationPriority;
  252.  
  253.  
  254. enum {
  255.     WSIJustificationSetMarkMask    = 0x80
  256. };
  257.  
  258. struct WSIJustificationStateEntry {
  259.     WSIJustificationPriority        markPriority;                /* non-zero priorities means insertion */
  260.     WSIJustificationPriority        priority;
  261.     WSIStateOffset                    newState;
  262. };
  263. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  264.  
  265. typedef unsigned short WSIJustificationClasses;
  266.  
  267.  
  268. enum {
  269.     wsiJustEndOfLineClass        = 0,
  270.     wsiJustEndOfRunClass        = 1,
  271.     wsiJustDeletedGlyphClass    = 2,
  272.     wsiJustUserDefinedClass        = 3
  273. };
  274.  
  275. typedef unsigned short WSIJustificationStates;
  276.  
  277.  
  278. enum {
  279.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  280.     wsiStartOfRunState            = 1,
  281.     wsiUserDefinedState            = 2
  282. };
  283.  
  284. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  285. typedef UInt8 WSIJustificationClassOffset;
  286.  
  287. struct WSIJustificationStateTable {
  288.     short                            maxPriorities;
  289.     unsigned short                    rowWidth;                    /* width of a state table row in bytes */
  290.     short                            classTableOffset;
  291.     short                            stateTableOffset;
  292. };
  293. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  294.  
  295. struct WSIJustificationHeader {
  296.     short                            version;
  297.     short                            format;
  298.     Point                            scaling;                    /* numer/denom scaling of priority weights <7> */
  299.     unsigned short                    spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  300.     unsigned short                    justStringOffset;            /* offset to justification string */
  301.     WSIJustificationStateTable        stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  302. };
  303. typedef struct WSIJustificationHeader WSIJustificationHeader;
  304.  
  305. /* Line Layout's Property table version <11> */
  306.  
  307. enum {
  308. /* v1.0 */
  309.     currentPropsTableVersion    = 0x00010000
  310. };
  311.  
  312. enum {
  313. /* ??? is this right */
  314.     kCharToGlyphCurrentVersion    = 0100
  315. };
  316.  
  317. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  318. enum {
  319.     kScriptsDefaultJustWeight    = -1
  320. };
  321.  
  322. struct WSIGlyphInfoRec {
  323.     UInt8                            qdChar;
  324.     SInt8                            rightToLeft;                /* !0 means rightToLeft, 0 means leftToRight */
  325.     short                            fontID;
  326.     short                            originalOffset;                /* or negative original offset if not in original text input */
  327.     unsigned short                    unused;                        /* long-align */
  328. };
  329. typedef struct WSIGlyphInfoRec WSIGlyphInfoRec, **WSIGlyphInfoHandle;
  330.  
  331. typedef Handle WSILayoutHandle;
  332.  
  333. extern pascal WSILayoutHandle NewWSILayout(WSILayoutHandle layoutH, Ptr text, short txLength, short lineDirection, unsigned long flags, OSErr *err)
  334.  FOURWORDINLINE(0x2F3C, 0X8414, 0x0040, 0xA8B5);
  335. extern pascal WSILayoutHandle JustifyWSILayout(WSILayoutHandle layoutH, Fixed slop, short priorityWeight, JustStyleCode styleRunPosition, Point numer, Point denom, OSErr *err)
  336.  FOURWORDINLINE(0x2F3C, 0x8418, 0x0042, 0xA8B5);
  337. extern pascal Fixed MeasureWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  338.  FOURWORDINLINE(0x2F3C, 0x840C, 0x0044, 0xA8B5);
  339. extern pascal void DrawWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  340.  FOURWORDINLINE(0x2F3C, 0x800C, 0x0046, 0xA8B5);
  341. /* "low-level" routines */
  342. extern pascal WSIGlyphInfoHandle GetWSILayoutParts(WSILayoutHandle layoutH, WSIGlyphInfoHandle destH, short *numGlyphs, OSErr *err)
  343.  FOURWORDINLINE(0x2F3C, 0x8410, 0x0048, 0xA8B5);
  344. extern pascal void DrawWSIGlyphs(short length, Ptr qdCodes, Point numer, Point denom)
  345.  FOURWORDINLINE(0x2F3C, 0x800E, 0x004A, 0xA8B5);
  346. extern pascal Fixed xMeasureWSIGlyphs(Ptr *qdCodes, short length, Point numer, Point denom)
  347.  FOURWORDINLINE(0x2F3C, 0x840E, 0x004C, 0xA8B5);
  348.  
  349. #if PRAGMA_IMPORT_SUPPORTED
  350. #pragma import off
  351. #endif
  352.  
  353. #if PRAGMA_ALIGN_SUPPORTED
  354. #pragma options align=reset
  355. #endif
  356.  
  357. #ifdef __cplusplus
  358. }
  359. #endif
  360.  
  361. #endif /* __WORLDSCRIPT__ */
  362.